//
//  CTRequestUtil.h
//  ConstellationTalk_0.1
//
//  Created by riley on 15/4/21.
//  Copyright (c) 2015年 riley chu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

typedef void (^downloadCompletionSuccessBlock)(NSData * data);
typedef void (^downloadFailedBlock)(NSError * error);

typedef void (^imgRequestCompletionSuccessBlock)(UIImage * img);
typedef void (^imgRequestFailedBlock)(NSError * error);



@interface CTRequestUtil : NSObject


//单例模式

+(CTRequestUtil *)shareInstance;



//静态模式

//get
+(void)sendAsyGetRequest:(NSString *)url
               withParam:(NSMutableDictionary *)param
withCompletionSuccessHandler:(downloadCompletionSuccessBlock)successBlock
       withFailedHandler:(downloadFailedBlock)failedBlock;

//post
+(void)sendAsyPostRequest:(NSString *)url
                withParam:(NSMutableDictionary *)param
withCompletionSuccessHandler:(downloadCompletionSuccessBlock)successBlock
       withFailedHandler:(downloadFailedBlock)failedBlock;

//请求图片 get

+(UIImage *)requestImageWithUrl:(NSString *)url;

+(void)requestImgWithUrl:(NSString *)url
withCompletionSuccessHandler:(imgRequestCompletionSuccessBlock)successBlock
       withFailedHandler:(imgRequestFailedBlock)failedBlock;



@end
